package com.restaurant.application.indexes.consumptionlist;

import com.nebutown.commonunits.dataface.definitions.TableData;
import com.nebutown.description.DataTypes;
import com.nebutown.description.IndexGen;
import com.nebutown.description.UnitDescription;
import com.nebutown.description.data.Contributor;
import com.nebutown.description.data.IndexUnit;
import com.nebutown.description.data.SQLColumn;
import com.restaurant.application.consumption.Consumption;
import com.restaurant.application.genshanguser.GenShangUser;
import com.restaurant.application.indexes.consumptionlist.mysql.ConsumptionListCriteria;

public class AssistConsumptionListDesc extends UnitDescription {

    public static void main(String[] args) {
        UnitDescription desc = UnitDescription.basicUnit(AssistConsumptionList.class, null);
        desc.nextBean("ConsumptionListPageData")
                .add("tableData", TableData.class)
                .add("doSearchPath", String.class)
        ;
        desc.nextBean("BandBean")
                .add("shopId", String.class)
                .add("number", String.class)
                .add("time", Long.class)
                .add("deskNumber", Long.class)
                .add("totalPrice", Double.class)
                .add("finalPrice", Double.class)
                .add("ensurePrice", Double.class)
                .add("customerId", String.class)
                .add("phone", String.class)

        ;


        desc
                .addUiFunction("viewConsumption", null)
                .addUiFunction("doSearchPath", ConsumptionListCriteria.class.getName())
        ;

        desc.run("./");
        IndexGen.run(getDescription(), "src/main/java");
    }

    public static IndexUnit getDescription() {
        return new IndexUnit()
                .withName("ConsumptionList")
                .withPackageName(AssistConsumptionListDesc.class.getPackage().getName() + ".mysql")
                .withSrcLocation("./")
                .addContributors(new Contributor()
                        .withName("consumptionUid")
                        .withNullable(false)
                        .withUnique(true)
                        .withUnitType(Consumption.class.getName())
                        .addContribution(new SQLColumn()
                                .withName("totalPrice")
                                .withType(DataTypes.DOUBLE)
                                .withLabel("总价")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("finalPrice")
                                .withType(DataTypes.DOUBLE)
                                .withLabel("最终价格")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("time")
                                .withType(DataTypes.LONG)
                                .withLabel("支付时间")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("shopUID")
                                .withType(DataTypes.STRING)
                                .withLabel("门店")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("shopName")
                                .withType(DataTypes.STRING)
                                .withLabel("门店的名字")
                                .withWidth(255))

                        .addContribution(new SQLColumn()
                                .withName("accumulatePoints")
                                .withType(DataTypes.LONG)
                                .withLabel("获得的积分")
                                .withWidth(255)))

                .addContributors(new Contributor()
                        .withName("customerUid")
                        .withNullable(false)
                        .withUnique(true)
                        .withUnitType(GenShangUser.class.getName())
                        .addContribution(new SQLColumn()
                                .withName("customerName")
                                .withType(DataTypes.STRING)
                                .withLabel("客户名")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("weChatId")
                                .withType(DataTypes.STRING)
                                .withLabel("客户微信Id")
                                .withWidth(255))
                );
    }
}
